<template>
    <div>
        <el-dialog title="提交反馈" :visible.sync="feedDialog" width="50%">
            <el-form label-width="130px" :rules="rules" :model="ruleForm" style="width: 80%;margin-left:40px;"
                size="small">
                <el-form-item label="反馈类型:">
                    <el-select v-model="ruleForm.feedbackType" placeholder="请选择案件类型">
                        <el-option label="催办" value="1"></el-option>
                        <el-option label="举报" value="2"></el-option>
                        <el-option label="咨询" value="3"></el-option>
                        <el-option label="投诉" value="4"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="反馈内容:" prop="feedbackContent" required>
                    <el-input type="textarea" placeholder="请输入内容" v-model="ruleForm.feedbackContent" maxlength="255"
                        show-word-limit>
                    </el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="cancelDialog">取 消</el-button>
                <el-button type="danger" @click="createFeed()">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
import { mapState } from 'vuex'
import { taskFeedback } from '@/api/case'
export default {
    data() {
        return {
            feedDialog: false,
            ruleForm: {
                feedbackType: '1',
                feedbackState: '1'
            },
            rules: {
                feedbackContent: [{ required: true, message: '请输入反馈内容', trigger: 'blur' },]
            }
        }
    },
    created() {
    },
    computed: {
        ...mapState({
            userInfo: state => state.user.userInfo
        })
    },
    methods: {
        showFeedDialog(taskId) {
            this.ruleForm.taskId = taskId
            this.feedDialog = true;
        },
        createFeed() {
            const params = {
                createUser: this.userInfo.userId,
                createUserName: this.userInfo.userName
            }
            this.ruleForm = Object.assign(this.ruleForm, params)
            taskFeedback(this.ruleForm).then(() => {
                this.feedDialog = false;
                this.ruleForm = {
                    feedbackType: '1',
                    feedbackState: '1',
                    feedbackContent: ''
                }
                this.$message({
                    message: '反馈成功',
                    type: 'success'
                })
            })
        },
        cancelDialog() {
            this.feedDialog = false
            this.ruleForm = {
                feedbackType: '1',
                feedbackState: '1',
                feedbackContent: ''
            }
        }
    },
}
</script>
<style lang='scss' scoped></style>
